<?php
include 'user_update_lib.php';
$a_UserID = get_user_info($f_userid, $db_conn);
?>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
    <h3>Cập Nhật Lớp Mới Cho Khóa <?= $a_KhoaHoc_Info['start_year'] + 1 ?> - <?= $a_KhoaHoc_Info['start_year'] + 2 ?></h3>
</div>
<form id="form_new_class_modal" action="user_update_execute.php?action=update-new-class" method="post">
    <div class="modal-body">
        <div class="alert alert-error hide">
            <button class="close" data-dismiss="alert"></button>
            Kiểm tra lại thông tin bên dưới.
        </div>
        <div class="row-fluid">
            <div class="span12 ">
                <div class="control-group">
                    <div class="controls">
                        <?php foreach ($a_UserID as $s_Tmp_UserID => $O_User) { ?>
                            <a class="btn mini rm-user" href="#">
                                <?= $O_User->saint ?> <?= $O_User->username ?> <i class="icon-remove"></i>
                                <input type="hidden" name="userid[<?= $s_Tmp_UserID ?>]" value="<?= $s_Tmp_UserID ?>" />
                            </a>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span4">
                <div class="control-group">
                    <label class="control-label" >Ngành</label>
                    <div class="controls">
                        <select name="team" class="m-wrap span12">
                            <?php foreach ($a_Nganh as $v_key => $v_value) { ?>
                                <option value="<?= $v_key ?>"><?= $v_value ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
            </div>
            <div class="span4">
                <div class="control-group">
                    <label class="control-label" >Cấp</label>
                    <div class="controls">
                        <select name="level" class="m-wrap span12">
                            <option value=""></option>
                            <?php foreach ($a_Cap as $v_key => $v_value) { ?>
                                <option value="<?= $v_key ?>"><?= $v_value ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
            </div>
            <div class="span4">
                <div class="control-group">
                    <label class="control-label" >Đội</label>
                    <div class="controls">
                        <select name="crew" class="m-wrap span12">
                            <option value=""></option>
                            <?php foreach ($a_Doi as $v_key => $v_value) { ?>
                                <option value="<?= $v_key ?>"><?= $v_value ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" data-dismiss="modal" class="btn">Thoát</button>
        <button type="submit" class="btn blue btn-save">Lưu</button>
    </div>
</form>
<script type="text/javascript">
    var frm_new_class = $('#form_new_class_modal');

    frm_new_class.validate({
        submitHandler: function (form) {
            $('.modal-footer', frm_new_class).html('<img src="assets/img/loading.gif"/>');
            
            $.ajax({
                url: $(form).attr('action'),
                type: $(form).attr('method'),
                data: $(form).serialize(),
                dataType: 'json'
            })
            .done(function(response) {
                
                if (response.code == 200) {
                    $('.modal-footer', frm_new_class).html(' <span>Đã Cập Nhật<span>');
                }
                else {
                    $('.modal-footer', frm_new_class).html(' <span>Lỗi<span>');
                }
            });
        }
    });
    
    frm_new_class.find('.rm-user').click(function () {
        $(this).remove();
    });
    
    $(".datepicker").datepicker();
</script>